//-----------------------------------------------------------------------------
// Name: Rob Town
// Auth: Robert Darty
//-----------------------------------------------------------------------------

#include "RobTown.h"

#include "SharedConstants.h"

#include "corona/corona.h"

#include <GL/glut.h>
#include <math.h>

//-----------------------------------------------------------------------------
// Globals:
//-----------------------------------------------------------------------------
cRobTown gRobTown;


//-----------------------------------------------------------------------------
// Functions:
//-----------------------------------------------------------------------------
cRobTown* GetRobTown()
{
	return &gRobTown;
}

//-----------------------------------------------------------------------------
// class cDude:
//-----------------------------------------------------------------------------
cRobTown::cRobTown() :
	mXPosition(0),
	mZPosition(0)
{

}

cRobTown::~cRobTown()
{
}

//Moves the town
void cRobTown::Move(int x, int z)
{
	mXPosition = x;
	mZPosition = z;
}

//Draws it
void cRobTown::Draw()
{

	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();
	//glEnable(GL_LIGHTING);
	glBegin(GL_QUADS);

	glColor3f( 0.96f, 0.64f, 0.39f );

	glNormal3f(0.0f,1.0f, 0.0f);
	glVertex3f( 250.0f, 0, 250.0f );
	glVertex3f( 250.0f, 0, -250.0f );
	glVertex3f( -250.0f, 0, -250.0f );
	glVertex3f( -250.0f, 0, 250.0f );
	

	glEnd();

	glBegin( GL_QUADS );

	//perimeter roads
	glColor3f( 0.5f, 0.5f, 0.5f );
		glNormal3f(0.0f,1.0f, 0.0f);
	glVertex3f( 250.0f, 0.01f, -240.0f );
	glVertex3f( 250.0f, 0.01f, -250.0f );
	glVertex3f( -250.0f, 0.01f, -250.0f );
	glVertex3f( -250.0f, 0.01f, -240.0f );
	glNormal3f(0.0f,1.0f, 0.0f);
	glVertex3f( -240.0f, 0.01f, -240.0f );
	glVertex3f( -250.0f, 0.01f, -240.0f );
	glVertex3f( -250.0f, 0.01f, 250.0f );
	glVertex3f( -240.0f, 0.01f, 250.0f );

	glNormal3f(0.0f,1.0f, 0.0f);
	glVertex3f( -240.0f, 0.01f, 240.0f );
	glVertex3f( -240.0f, 0.01f, 250.0f );
	glVertex3f( 250.0f, 0.01f, 250.0f );
	glVertex3f( 250.0f, 0.01f, 240.0f );

	glNormal3f(0.0f,1.0f, 0.0f);
	glVertex3f( 240.0f, 0.01f, 240.0f );
	glVertex3f( 250.0f, 0.01f, 240.0f );
	glVertex3f( 250.0f, 0.01f, -240.0f );
	glVertex3f( 240.0f, 0.01f, -240.0f );

	glNormal3f(0.0f,1.0f, 0.0f);
	//town square
	glVertex3f( 30.0f, 0.01f, 30.0f );
	glVertex3f( 30.0f, 0.01f, -30.0f );
	glVertex3f( -30.0f, 0.01f, -30.0f );
	glVertex3f( -30.0f, 0.01f, 30.0f );

	glNormal3f(0.0f,1.0f, 0.0f);
	//roads to town square
	glVertex3f( 240.0f, 0.01f, 5.0f );
	glVertex3f( 240.0f, 0.01f, -5.0f );
	glVertex3f( 30.0f, 0.01f, -5.0f );
	glVertex3f( 30.0f, 0.01f, 5.0f );

	glNormal3f(0.0f,1.0f, 0.0f);
	glVertex3f( -30.0f, 0.01f, 5.0f );
	glVertex3f( -30.0f, 0.01f, -5.0f );
	glVertex3f( -240.0f, 0.01f, -5.0f );
	glVertex3f( -240.0f, 0.01f, 5.0f );

	glNormal3f(0.0f,1.0f, 0.0f);
	glVertex3f( -5.0f, 0.01f, -30.0f );
	glVertex3f( 5.0f, 0.01f, -30.0f );
	glVertex3f( 5.0f, 0.01f, -240.0f );
	glVertex3f( -5.0f, 0.01f, -240.0f );

	glNormal3f(0.0f,1.0f, 0.0f);
	glVertex3f( 5.0f, 0.01f, 30.0f );
	glVertex3f( -5.0f, 0.01f, 30.0f );
	glVertex3f( -5.0f, 0.01f, 240.0f );
	glVertex3f( 5.0f, 0.01f, 240.0f );

	glNormal3f(0.0f,1.0f, 0.0f);
	//other roads bottom half
	glVertex3f( 240.0f, 0.01f, 90.0f );
	glVertex3f( 240.0f, 0.01f, 80.0f );
	glVertex3f( -240.0f, 0.01f, 80.0f );
	glVertex3f( -240.0f, 0.01f, 90.0f );

	glNormal3f(0.0f,1.0f, 0.0f);
	glVertex3f( 240.0f, 0.01f, 170.0f );
	glVertex3f( 240.0f, 0.01f, 160.0f );
	glVertex3f( -240.0f, 0.01f, 160.0f );
	glVertex3f( -240.0f, 0.01f, 170.0f );

	glNormal3f(0.0f,1.0f, 0.0f);
	//other roads top half
	glVertex3f( 240.0f, 0.01f, -80.0f );
	glVertex3f( 240.0f, 0.01f, -90.0f );
	glVertex3f( -240.0f, 0.01f, -90.0f );
	glVertex3f( -240.0f, 0.01f, -80.0f );

	glNormal3f(0.0f,1.0f, 0.0f);
	glVertex3f( 240.0f, 0.01f, -160.0f );
	glVertex3f( 240.0f, 0.01f, -170.0f );
	glVertex3f( -240.0f, 0.01f, -170.0f );
	glVertex3f( -240.0f, 0.01f, -160.0f );

	glEnd();
	//glDisable(GL_LIGHTING);
	glPopMatrix();
}

